// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-03 12:23
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.BinaryAlgorithms;

public class CountBits {
    /**
     * 比特位计数
     *
     * @param n
     * @return
     */
    public int[] countBits(int n) {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            ans[i] = Integer.bitCount(i);
        }
        return ans;
    }
}
